package com.luban.springboot.config;

import static org.springframework.web.reactive.function.server.RequestPredicates.GET;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.server.RouterFunction;
import org.springframework.web.reactive.function.server.RouterFunctions;
import org.springframework.web.reactive.function.server.ServerResponse;

import com.luban.springboot.handler.UserHandler;

@Configuration
public class RouterConfig {
	
	@Autowired
	private UserHandler userHandler;
	
	@Bean
    public RouterFunction<ServerResponse> userInfoRouter() {
		return RouterFunctions.route(GET("/user"),req -> userHandler.getInfo(req));
		//可直接多接地址  例如
		//.andRoute(GET("/realMsg"), userHandler::realMsg);
    }
	
	@Bean
    public RouterFunction<ServerResponse> userlistRouter() {
		return RouterFunctions.route(GET("/list"),userHandler::getList);
    }
	
	@Bean
    public RouterFunction<ServerResponse> realMsg() {
		return RouterFunctions.route(GET("/realMsg"),userHandler::getRealMsg);
    }
}
